/**
 * 微信工具箱
 * 
 * Public/js/backend/mer_wx_tools.js
 * Zix @ 2015-09-09
 */

var MerWxTools = {
  config: {
  },
  init: function (config) {
    var _this = this;
    $.extend(_this.config, config);
    Layout.set_menu_select(_this.config.menu_id);

    loading();
    _this.init_btn();
    $('#redirect_form')[0].reset();
  },
    
  init_btn: function () {
    var _this = this;

    $(document).on("blur" , '#redirect_url_org , #redirect_scope , #redirect_state' , function(){
      var url = _this.config.read_redirect_url ;
      var data = $('#redirect_form').serializeObject();
      
      $.post( url , data , function(ret){
        $('#url_tar').val(ret);
      });
    });
    
    //保存菜单
    $(document).on('click', '#save_menu_btn', function (e) {
      e.preventDefault();
      _this.update_wx_menu_data();
      var url = _this.config.save_menu_url ;
      var data = {
        wx_id : _this.config.wx_id ,
        data : _this.config.wx_menu 
      }
      
      $.post( url , data , function(ret){
        tips( ret.info );
      });
    });
    
    
  },
};







